<template>
	<view class="box box-card">
		<uni-forms ref="feedForm" :modelValue="feedForm" :rules="formRules" errShowType="toast" :border="false">
			<uni-forms-item name="content">
				<view class="uni-mb-8 uni-mt-3">反馈或建议</view>
				<uni-easyinput type="textarea" v-model="feedForm.content" placeholder="请输入您的反馈或建议" maxlength="200"
					:autoHeight="true" :inputBorder="true"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item name="images">
				<upload :url="feedForm.images" :limit="9" @success="uploadImage"></upload>
			</uni-forms-item>
			<uni-forms-item>
				<button class="form-button uni-mt-10" @click="save">提交</button>
			</uni-forms-item>
		</uni-forms>
	</view>
</template>

<script>
	import upload from '@/components/upload/upload.vue'
	export default {
		components: {
			upload
		},
		data() {
			return {
				feedForm: {
					content: '',
					images: ''
				},
				formRules: {
					content: {
						rules: [{
							required: true,
							errorMessage: '请输入您的反馈或建议'
						}]
					}
				}
			}
		},
		methods: {
			uploadImage(e) {
				this.feedForm.images = e;
			},
			save() {
				this.$refs.feedForm.validate().then(() => {
					this.$api.post('/appFeedback/add', this.feedForm).then(res => {
						uni.navigateBack({
							delta: 1,
							success: () => {
								this.$util.messageTip('提交成功')
							}
						})
					})
				})
			}
		}
	}
</script>
